<template>
  <div>
    <router-link to="/classify/comedyfilm" exact-active-class="active"
      >喜剧</router-link
    >
    <router-link to="/classify/cartoon" exact-active-class="active"
      >动漫</router-link
    >
    <router-link to="/classify/cate" exact-active-class="active"
      >美食</router-link
    >
    <router-link to="/classify/flower" exact-active-class="active"
      >鲜花</router-link
    >
    <hr />
    <div>
      <button @click="btn">点击随机</button>
    </div>
    <div>
      <h1>显示二级路由切换的页面↓</h1>
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [
        "/classify/comedyfilm",
        "/classify/cartoon",
        "/classify/cate",
        "/classify/flower",
      ],
    };
  },
  methods: {
    btn() {
      this.$router.push(
        this.list[Math.floor(Math.random() * this.list.length)]
      );
    },
  },
};
</script>

<style scoped>
.active {
  color: #f00;
}
a {
  margin-right: 5px;
}
</style>